import Instance from "../../Core/Utils/Instance";
import * as pb from '../proto/protoCmd.js';

export default class ProtoBufManager {
    private _protocolMap: {} = {};
    public static get ins(): ProtoBufManager {
        return Instance.get(ProtoBufManager);
    }
    /**
    * 获取 pb 属性
    * 通过 pb 属性来访问 protobuf 文件中的方法
    * 解决引用问题
    * @returns 返回 pb.protoCmd 类型的对象
    */
    public get pbCmd(): typeof pb.protoCmd {
        return pb[`default`].protoCmd as typeof pb.protoCmd;
    }
    /**初始化proto映射表 */
    public init(): void {
        // protoCmd.
        this._protocolMap = {};
        // this._protocolMap[`loginReq`] = this.pbCmd.loginReq;
        // this._protocolMap[`loginRes`] = this.pbCmd.loginRes;
        // this._protocolMap[`getAllPetReq`] = this.pbCmd.getAllPetReq;
        // this._protocolMap[`getAllPetRes`] = this.pbCmd.getAllPetRes;
        console.log(`init protocol map success`);
    }
    public get protocolMap(): object {
        return this._protocolMap;
    }
}